package vip.indo.web;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 田连印
 * @Date 2025/1/14 9:27
 * @Descripition
 */
@SpringBootApplication
@ComponentScan("vip.indo.**")
@RestController
@Slf4j
@EnableScheduling// 开启定时任务
public class Application {
    public static void main(String[] args) {
        ConfigurableApplicationContext run = SpringApplication.run(Application.class, args);
        // 获取配置信息
        ConfigurableEnvironment environment = run.getEnvironment();
        String port = environment.getProperty("server.port");
        String contextPath = environment.getProperty("server.servlet.context-path");
        log.info("""
                                
                -----------------------------------------------------
                Application Start
                BaseUrl\t:\t\t http://127.0.0.1:{}{},
                DocUrl\t:\t\t http://127.0.0.1:{}{}/doc.html
                -----------------------------------------------------
                                
                """,port,contextPath,port,contextPath);
    }

    @GetMapping
    public String hello() {
        return "hello";
    }
}
